package com.server.llh.llhserverwork.adapter.base;

import java.util.List;


public class ListViewDataAdapter<T> extends ListViewDataAdapterBase<T> {

    protected List<T> mItemDataList;

    public ListViewDataAdapter(List<T> itemDataList) {
    	update(itemDataList);
    }
    
    @Override
    public void update(List<T> list){
    	this.mItemDataList = list;
    	this.notifyDataSetChanged();
    }
    
    public List<T> getDataList() {
        return mItemDataList;
    }

    @Override
    public int getCount() {
    	if(mItemDataList == null){
    		return 0;
    	}else{
    		return mItemDataList.size();
    	}
    }

    @Override
    public T getItem(int position) {
        if (mItemDataList.size() <= position || position < 0) {
            return null;
        }
        return mItemDataList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }
}
